<% content_for :css do %>
  <%= stylesheet_link_tag 'new_or_edit','order_mades_new' %>
<% end %>
<%= form_for @order_made,  
      :html => {
        :id => :sf_form
      } do |f| %>
<div class='form'>
  <div class='top'>
    <div class='title corner'>
      新增订做单 New!
    </div>
  </div>
    <div class='body'>
    <table>
      <tr>
        <th>
          订单号：
        </th>
        <td class='order_made_no'>
          <%= @order_made.order_made_no %>
          <%= f.text_field :order_made_no, :class => :hidden %>
        </td>
      </tr>
      <tr>
        <th>
          日期：
        </th>
        <td class='date'>
          <%= f.date_select :order_made_on %>
        </td>
      </tr>
      <tr>
        <th>
          待下单厂家：
        </th>
        <td>
          <%= f.select :factory_id, @factories.collect {|factory| [ factory.name, factory.id ] } %>
          <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
              $('#order_made_factory_id').change(function(){
                 $.ajax({
                   url: '<%= unsent_order_made_items_order_mades_url %>',
                   data: 'factory_id=' + this.value                   
                 })
              });
            })
          </script>
        </td>
      </tr>
      <tr>
        <th>
          订做项：
        </th>
        <td id='order_made_items'>
          <%= render( :partial => 'unsent_order_made_items.html', :locals => { :unsent_order_made_items => @unsent_order_made_items }) %>
        </td>
      </tr>
      <tr>
        <th>
          金额：
        </th>
        <td>
          <%= f.text_field :order_made_price %>
        </td>
      </tr>
      <tr>
        <th>
          备注：
        </th>
        <td>
          <%= f.text_area :remark, :rows => 10 %>
        </td>
      </tr>
      <tr>
        <th></th>
        <td>
          <%= link_to_function '保存', '$("#sf_form").submit()', :class => 'bb' %>
          <%= link_to '返回', order_mades_url , :class => 'bb go_back' %>          
        </td>
      </tr>
    </table>
  </div>

</div>    
<% end %>  